<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
p span{color:#fff; background-color:red;}
</style>
</head>
<body>
<p>在新学期里有新学期的样子开始新学期</p>
<input type="text"/>
<input type="button" value="查找"/>
<input type="text"/>
<input type="button" value="替换"/>
<script>
var oP = document.getElementsByTagName("p")[0];
var aInput = document.getElementsByTagName("input");
var str = oP.innerHTML;
aInput[1].onclick = function (){
	var s = aInput[0].value;
	oP.innerHTML = str.split(s).join("<span>"+s+"</span>");
}
aInput[3].onclick = function (){
	var s1 = aInput[0].value;
	var s2 = aInput[2].value;
	oP.innerHTML = str.split(s1).join("<span>"+s2+"</span>");
}
</script>
</body>
</html>
